<?php

namespace App\Models;

use App\Observers\NoticeObserver;
use Illuminate\Database\Eloquent\Model;

class Message extends Model
{
    protected $table = 'messages';
    protected $fillable = ['title','content','read','send_uuid','accept_uuid','flag'];

    public $read_status=[
        '1'=>'未读',
        '2'=>'已读'
    ];


    // 使用laravel提供模型类初始化方法  方法中最早执行的
    protected static function boot() {
        parent::boot();
        // 注册自定义观察类
        self::observe(NoticeObserver::class);
    }

    // 房东
    public function owner() {
        return $this->belongsTo(FangOwner::class, 'send_uuid');
    }
}
